<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/font-awesome.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/ionicons.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/skins/all-skins.min.css">
<title>综合管理系统</title>
</head>
<style>
html {
	overflow: hidden;
}

.menu_tab {
	margin-right: 2px;
	background: #D3D3D4;
}
</style>
<body class="hold-transition skin-blue sidebar-mini fixed">
	<%-- <%   
	System.out.println(session.getAttribute("sysUser").toString()); //从session里把a拿出来，并赋值给M  
%>   --%>
	<div class="wrapper">
		<header class="main-header">
			<!-- Logo -->
			<a href="#" class="logo"> <!-- mini logo for sidebar mini 50x50 pixels --> <span class="logo-mini"><b>综合</b></span> <!-- logo for regular state and mobile devices --> <span class="logo-lg"><b>综合管理系统</b></span>
			</a>
			<!-- Header Navbar: style can be found in header.less -->
			<nav class="navbar navbar-static-top">
				<!-- Sidebar toggle button-->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
				</a>

				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">
						<!-- Messages: style can be found in dropdown.less-->
						<!-- 						<li class="dropdown messages-menu"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-envelope-o"></i> <span class="label label-success">4</span> -->
						<!-- 						</a> -->
						<!-- 							<ul class="dropdown-menu"> -->
						<!-- 								<li class="header">You have 4 messages</li> -->
						<!-- 								<li> -->
						<!-- 									inner menu: contains the actual data -->
						<!-- 									<ul class="menu"> -->
						<!-- 										<li> -->
						<!-- 											start message <a href="#"> -->
						<!-- 												<h4> -->
						<!-- 													Support Team <small><i class="fa fa-clock-o"></i> 5 mins</small> -->
						<!-- 												</h4> -->
						<!-- 												<p>Why not buy a new awesome theme?</p> -->
						<!-- 										</a> -->
						<!-- 										</li> -->
						<!-- 										end message -->
						<!-- 										<li><a href="#"> -->
						<!-- 												<h4> -->
						<!-- 													AdminLTE Design Team <small><i class="fa fa-clock-o"></i> 2 hours</small> -->
						<!-- 												</h4> -->
						<!-- 												<p>Why not buy a new awesome theme?</p> -->
						<!-- 										</a></li> -->
						<!-- 										<li><a href="#"> -->
						<!-- 												<h4> -->
						<!-- 													Developers <small><i class="fa fa-clock-o"></i> Today</small> -->
						<!-- 												</h4> -->
						<!-- 												<p>Why not buy a new awesome theme?</p> -->
						<!-- 										</a></li> -->
						<!-- 										<li><a href="#"> -->
						<!-- 												<h4> -->
						<!-- 													Sales Department <small><i class="fa fa-clock-o"></i> Yesterday</small> -->
						<!-- 												</h4> -->
						<!-- 												<p>Why not buy a new awesome theme?</p> -->
						<!-- 										</a></li> -->
						<!-- 										<li><a href="#"> -->
						<!-- 												<h4> -->
						<!-- 													Reviewers <small><i class="fa fa-clock-o"></i> 2 days</small> -->
						<!-- 												</h4> -->
						<!-- 												<p>Why not buy a new awesome theme?</p> -->
						<!-- 										</a></li> -->
						<!-- 									</ul> -->
						<!-- 								</li> -->
						<!-- 								<li class="footer"><a href="#">See All Messages</a></li> -->
						<!-- 							</ul></li> -->
						<li class="dropdown user user-menu"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="hidden-xs">${sessionScope.userAccount}</span>
						</a> <!-- 							<ul class="dropdown-menu"> --> <!-- 								User image --> <%-- 								<li class="user-header"><img src="${pageContext.request.contextPath}/img/user2-160x160.jpg" class="img-circle" alt="User Image"> --%> <!-- 									<p> --> <!-- 										Alexander Pierce - Web Developer <small>Member since Nov. 2012</small> --> <!-- 									</p></li> --> <!-- 								Menu Body --> <!-- 								<li class="user-body"> --> <!-- 									<div class="row"> --> <!-- 										<div class="col-xs-4 text-center"> --> <!-- 											<a href="#">Followers</a> --> <!-- 										</div> --> <!-- 										<div class="col-xs-4 text-center"> --> <!-- 											<a href="#">Sales</a> --> <!-- 										</div> --> <!-- 										<div class="col-xs-4 text-center"> --> <!-- 											<a href="#">Friends</a> --> <!-- 										</div> --> <!-- 									</div> /.row --> <!-- 								</li> --> <!-- 								Menu Footer --> <!-- 								<li class="user-footer"> --> <!-- 									<div class="pull-left"> -->
							<!-- 										<a href="#" class="btn btn-default btn-flat">Profile</a> --> <!-- 									</div> --> <!-- 									<div class="pull-right"> --> <!-- 										<a href="#" class="btn btn-default btn-flat">Sign out</a> --> <!-- 									</div> --> <!-- 								</li> --> <!-- 							</ul> --></li>
						<!-- Control Sidebar Toggle Button -->
						<li class="dropdown user user-menu"><a href="#" class="dropdown-toggle" data-toggle="dropdown" onclick="showModal()"> <span class="hidden-xs">修改密码</span>
						</a></li>
						<li><a href="javascript:;" onclick="signOut();"><i class="fa fa-power-off"></i></a></li>
						<li><a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a></li>
					</ul>
				</div>
			</nav>
		</header>
		<aside class="main-sidebar">
			<!-- sidebar: style can be found in sidebar.less -->
			<section class="sidebar">
				<!-- Sidebar user panel -->
				<!-- search form -->
				<!-- /.search form -->
				<!-- sidebar menu: : style can be found in sidebar.less -->
				<ul class="sidebar-menu"></ul>
			</section>
			<!-- /.sidebar -->
		</aside>
		<div class="content-wrapper" id="content-wrapper" style="min-height: 421px;">
			<!--bootstrap tab风格 多标签页-->
			<div class="content-tabs">
				<button class="roll-nav roll-left tabLeft" onclick="scrollTabLeft()">
					<i class="fa fa-backward"></i>
				</button>
				<nav class="page-tabs menuTabs tab-ui-menu" id="tab-menu">
					<div class="page-tabs-content" style="margin-left: 0px;"></div>
				</nav>
				<button class="roll-nav roll-right tabRight" onclick="scrollTabRight()">
					<i class="fa fa-forward" style="margin-left: 3px;"></i>
				</button>
				<div class="btn-group roll-nav roll-right">
					<button class="dropdown tabClose" data-toggle="dropdown">
						页签操作<i class="fa fa-caret-down" style="padding-left: 3px;"></i>
					</button>
					<ul class="dropdown-menu dropdown-menu-right" style="min-width: 128px;">
						<li><a class="tabReload" href="javascript:refreshTab();">刷新当前</a></li>
						<li><a class="tabCloseCurrent" href="javascript:closeCurrentTab();">关闭当前</a></li>
						<li><a class="tabCloseAll" href="javascript:closeOtherTabs(true);">全部关闭</a></li>
						<li><a class="tabCloseOther" href="javascript:closeOtherTabs();">除此之外全部关闭</a></li>
					</ul>
				</div>
				<button class="roll-nav roll-right fullscreen" onclick="App.handleFullScreen()">
					<i class="fa fa-arrows-alt"></i>
				</button>
			</div>
			<div class="content-iframe " style="background-color: #ffffff;">
				<div class="tab-content " id="tab-content"></div>
			</div>
		</div>
		<footer class="main-footer">
			<div class="pull-right hidden-xs">
				<b>Version</b> 1.0
			</div>
			<!-- 			Copyright © 2018 武汉市航天创想科技有限公司 All Rights Reserved 鄂ICP备846200570号 -->
			&nbsp;
		</footer>
		<aside class="control-sidebar control-sidebar-dark">
			<div class="tab-content">
				<!-- Home tab content -->
				<div class="tab-pane" id="control-sidebar-home-tab"></div>
			</div>
		</aside>
		<div class="control-sidebar-bg"></div>
	</div>
	<div id="modal" class="modal fade" role="dialog" aria-labelledby="myLargeModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">修改密码</h4>
				</div>
				<div class="modal-body">

					<div class="input-group">
						<span class="input-group-addon">原密码:</span> <input type="text" class="form-control" id="oldPass">
					</div>
					<br>
					<div class="input-group">
						<span class="input-group-addon">新密码:</span> <input type="text" class="form-control" id="newPass">
					</div>
					<br>
					<div class="input-group">
						<span class="input-group-addon">确认密码:</span> <input type="text" class="form-control" id="newPass1">
					</div>
					<br>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" onclick="updatePass();">提交</button>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
<script src="${pageContext.request.contextPath}/js/app.js"></script>
<script src="${pageContext.request.contextPath}/js/demo.js"></script>
<script src="${pageContext.request.contextPath}/js/app_iframe.js"></script>
<!-- layer -->
<script src="${pageContext.request.contextPath}/plugins/layer/2.4/layer.js"></script>
<script type="text/javascript">
	/**
	 * 本地搜索菜单
	 */
	function search_menu() {
		//要搜索的值
		var text = $('input[name=q]').val();
		var $ul = $('.sidebar-menu');
		$ul.find("a.nav-link").each(function() {
			var $a = $(this).css("border", "");
			//判断是否含有要搜索的字符串
			if ($a.children("span.menu-text").text().indexOf(text) >= 0) {
				//如果a标签的父级是隐藏的就展开
				$ul = $a.parents("ul");
				if ($ul.is(":hidden")) {
					$a.parents("ul").prev().click();
				}
				//点击该菜单
				$a.click().css("border", "1px solid");

			}
		});
	}

	$(function() {
		App.setbasePath("${pageContext.request.contextPath }/");
		App.setGlobalImgPath("img/");

		addTabs({
			id : '10008',
			title : '欢迎页',
			close : false,
			url : '${pageContext.request.contextPath }/jump_welcome',
			urlType : "relative"
		});
		App.fixIframeCotent();
		var roleId = "${sessionScope.roleId}";
		$.ajax({
			url : '${pageContext.request.contextPath}/selectByRole',
			type : 'post',
			data : {
				roleId : roleId
			},
			success : function(map) {
				var list = map['list'];
				var menus = [];
				for (var i = 0; i < list.length; i++) {
					var menu = [];
					menu.id = list[i].menuCode;
					menu.text = list[i].menuName;
					menu.icon = 'fa fa-folder-o';
					menu.children = [];
					for (var j = 0; j < list[i].menus.length; j++) {
						var children = [];
						children.id = list[i].menus[j].menuCode;
						children.text = list[i].menus[j].menuName;
						children.url = '${pageContext.request.contextPath }/' + list[i].menus[j].menuUrl;
						children.targetType = 'iframe-tab';
						children.icon = 'fa fa-circle-o';
						menu.children.push(children);
					}
					menus.push(menu);
				}
				$('.sidebar-menu').sidebarMenu({
					data : menus
				});
			}
		})
	});

	function IframeHeight() {
		return document.body.scrollHeight;
	}

	function signOut() {
		layer.confirm("是否要注销？", function(index) {
			window.location.href = "${pageContext.request.contextPath}/logout.do";
		})
	}

	function showModal() {
		$('#modal').modal({
			backdrop : 'static',
			keyboard : false
		});
	}

	function updatePass() {
		var oldPass = $("#oldPass").val();
		var newPass = $("#newPass").val();
		var newPass1 = $("#newPass1").val();
		if (oldPass === '' || newPass === '' || newPass1 === '') {
			layer.alert("新增的数据中填写不完整！");
			return;
		}
		if (newPass != newPass1) {
			layer.alert("两次输入的密码不一致！");
			return;
		}

		$.ajax({
			url : "${pageContext.request.contextPath}/updatePass",
			type : "post",
			data : {
				oldPass : oldPass,
				newPass : newPass
			},
			dataType : "json",
			success : function(data) {
				var result = data['result'];
				if (result == 1) {
					layer.msg('操作成功!', {
						icon : 1,
						time : 800
					});
					setTimeout(function() {
						window.location.href = "${pageContext.request.contextPath}/logout.do";
					}, 500);
				} else if (result == 2) {
					layer.msg('原密码错误!', {
						icon : 2,
						time : 800
					});
				} else {
					layer.msg('操作失败!', {
						icon : 2,
						time : 800
					});
				}
			}
		});
	}
</script>
</html>